import subprocess
import sys
# from randpass import gen_pass
import randpass

def adduser(uname, passwd, fname):
    data = '''user information:
%s: %s
'''
    subprocess.call('useradd %s' % uname, shell=True)
    subprocess.call(
        'echo %s | passwd --stdin %s' % (passwd, uname),
        shell=True
    )
    with open(fname, 'a') as fw:
        fw.write(data % (uname, passwd))

if __name__ == '__main__':
    uname = sys.argv[1]
    passwd = randpass.randpass()
    adduser(uname, passwd, '/tmp/user.txt')